from page.add_department_dialog import AddDepartmentDialog
from page.member_operation import MemberOperation
from page.contact_page import ContactPage
from page.import_cantact_page import ImportContactPage
from page.index_page import IndexPage


class PageFactory:
    '''
    1.简单工厂模式，专门定义一个类来负责创建其他类型的页面的实例
    2.提供了一个入口，比如添加了新的页面，其他研发调用代码的过程中，可以以factory为主
    '''
    def create_page_object(self, name, driver):
        if name == 'index':
            return IndexPage(driver)
        elif name == 'add_department_dialog':
            return AddDepartmentDialog(driver)
        elif name == 'member_operation':
            return MemberOperation(driver)
        elif name == 'contact_page':
            return ContactPage(driver)
        elif name == 'import_contact_page':
            return ImportContactPage(driver)
        elif name == 'member_op':
            return MemberOperation(driver)
        else:
            raise  Exception('此页面不在页面工厂中！')
